package com.zhouk.ams.controller;

import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Properties;
import java.util.Set;

/**
 * Create By Zhouke on 2017/12/07
 */
@RestController
@RequestMapping("/system")
public class SystemController implements EnvironmentAware{

    private String javaHome;

    @RequestMapping("/java_home")
    public String getJavaHome(){
        return javaHome;
    }


    @Override
    public void setEnvironment(Environment environment) {
        Properties properties = System.getProperties();
        Set<String> propertyNames = properties.stringPropertyNames();
        propertyNames.forEach(propertyName -> {
            System.out.println(propertyName);
        });
        System.out.println("PID"+ environment.getProperty("PID"));

        javaHome = environment.getProperty("JAVA_HOME");
    }
}
